home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / bankma.zip / BANKING.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-19  |  7KB  |  221 lines

  1. { ----------------------------------------------------------------------- }
  2. { Source file: BANKING.PAS                                                }
  3. { Application: Bank Manager                                               }
  4. { Version    : 1.0                                                        }
  5. { Created    : 08/19/91                                                   }
  6. { Updates    :                                                            }
  7. {                                                                         }
  8. { Description: Maintain bank account activity records.  Account types     }
  9. {              supported are: CHECKING, SAVINGS, CREDIT CARD, LOAN        }
  10. { Notes      :                                                            }
  11. { ----------------------------------------------------------------------- }
  12. program Banking;
  13.  
  14. uses Strings, WinTypes, WinProcs, WinDos, WObjects,
  15.      BankAcc, BankTrn;
  16.  
  17. {$R BANKING.RES}
  18.  
  19. const
  20.   AppName   = 'Bank Manager';
  21.   AppMenu   = 'BANKMENU';
  22.   AppIcon   = 'BANKICON';
  23.   AppAbout  = 'ABOUTDLG';
  24.   AccFile   = 'BANKACC.DTA';
  25.  
  26. const
  27.   sc_About     = 103;
  28.  
  29.   cm_NewAcc    = 101;
  30.   cm_OpenAcc   = 102;
  31.   cm_DeleteAcc = 103;
  32.   cm_ChooseAcc = 201;
  33.   cm_Checking  = 202;
  34.   cm_Savings   = 203;
  35.   cm_CreditCrd = 204;
  36.   cm_Transfer  = 205;
  37.   cm_AccBalance= 301;
  38.   cm_TransRec  = 302;
  39.  
  40. type
  41.   TMyApplication =
  42.     object( TApplication)
  43.       procedure InitMainWindow; virtual;
  44.     end;
  45.  
  46.  PMyWindow = ^TMyWindow;
  47.  TMyWindow =
  48.    object( TMDIWindow)
  49.      { Overridden methods }
  50.      constructor Init( ATitle: PChar; AMenu: HMenu);
  51.      destructor Done; virtual;
  52.      procedure GetWindowClass( var AWndClass: TWndClass); virtual;
  53.      procedure SetupWindow; virtual;
  54.      procedure WMDestroy( var Msg: TMessage); virtual wm_First + wm_Destroy;
  55.      { New methods }
  56.      procedure Sys103( var Msg: TMessage); virtual wm_First + wm_SysCommand;
  57.      procedure Menu101( var Msg: TMessage); virtual cm_First + cm_NewAcc;
  58.      procedure Menu102( var Msg: TMessage); virtual cm_First + cm_OpenAcc;
  59.      procedure Menu103( var Msg: TMessage); virtual cm_First + cm_DeleteAcc;
  60.      procedure Menu201( var Msg: TMessage); virtual cm_First + cm_ChooseAcc;
  61.      procedure Menu205( var Msg: TMessage); virtual cm_First + cm_Transfer;
  62.      procedure Menu301( var Msg: TMessage); virtual cm_First + cm_AccBalance;
  63.      procedure Menu302( var Msg: TMessage); virtual cm_First + cm_TransRec;
  64.      procedure Menu2( var Msg: TMessage); virtual cm_First + 2;
  65.    end;
  66.  
  67. {--------------------------------------------------}
  68. { TMyWindow's method implementations:              }
  69. {--------------------------------------------------}
  70.  
  71. { Overridden methods }
  72.  
  73. constructor TMyWindow.Init( ATitle: PChar; AMenu: HMenu);
  74. var
  75.   DC: HDC;
  76. begin
  77.   TMDIWindow.Init( ATitle, AMenu);
  78.  
  79.   DC := GetDC( HWindow);
  80.   Attr.X := 0;
  81.   Attr.Y := 0;
  82.   Attr.H := GetDeviceCaps( DC, VertRes) - 90;
  83.   Attr.W := GetDeviceCaps( DC, HorzRes);
  84.   ReleaseDC( HWindow, DC);
  85. end;
  86.  
  87. destructor TMyWindow.Done;
  88. begin
  89.   TMDIWindow.Done;
  90. end;
  91.  
  92. procedure TMyWindow.GetWindowClass(var AWndClass: TWndClass);
  93. begin
  94.   TMDIWindow.GetWindowClass( AWndClass);
  95.   AWndClass.hIcon := LoadIcon( HInstance, AppIcon);
  96. end;
  97.  
  98. procedure TMyWindow.SetupWindow;
  99. var
  100.   SysMenu: hMenu;
  101. begin
  102.   TMDIWindow.SetupWindow;
  103.  
  104.   SysMenu := GetSystemMenu( HWindow, FALSE);
  105.   AppendMenu( SysMenu, mf_Separator, 0, Nil);
  106.   AppendMenu( SysMenu, mf_String, sc_About, 'A&bout...');
  107.   DrawMenuBar( HWindow);
  108. end;
  109.  
  110. procedure TMyWindow.WMDestroy( var Msg: TMessage);
  111. begin
  112.   TMDIWindow.WMDestroy( Msg);
  113. end;
  114.  
  115. { NEW methods }
  116.  
  117. procedure TMyWindow.Sys103( var Msg: TMessage);
  118. begin
  119.   if Msg.WParam = sc_About then
  120.     Application^.ExecDialog( New( PDialog, Init( @Self, 'ABOUTDLG')))
  121.   else
  122.     DefWndProc( Msg);
  123. end;
  124.  
  125. procedure TMyWindow.Menu101( var Msg: TMessage);
  126. begin
  127.   Application^.ExecDialog( New( PAcc, Init( @Self, 'NEWACC')));
  128. end;
  129.  
  130. procedure TMyWindow.Menu102( var Msg: TMessage);
  131. begin
  132.   if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
  133.   begin
  134.     Application^.ExecDialog( New( PAcc, Init( @Self, 'OLDACC')));
  135.   end;
  136. end;
  137.  
  138. procedure TMyWindow.Menu103( var Msg: TMessage);
  139. var
  140.   AccF,
  141.   TmpF: file of AccRec;
  142.   AccR: AccRec;
  143. begin
  144.   if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
  145.     if MessageBox( HWindow, 'This account will be deleted. Are you sure?',
  146.                    'Account Manager', mb_IconQuestion or mb_YesNo) = id_Yes then
  147.     begin
  148.       assign( AccF, AccFile);
  149.       reset( AccF);
  150.       assign( TmpF, 'BANKACC.DEL');
  151.       rewrite( TmpF);
  152.       repeat
  153.         read( AccF, AccR);
  154.         if StrComp( AccR.AccNum, GAccNum) <> 0 then write( TmpF, AccR);
  155.       until FilePos( AccF) = FileSize( AccF);
  156.       close( AccF);
  157.       close( TmpF);
  158.       erase( AccF);
  159.       rename( TmpF, AccFile);
  160.     end;
  161. end;
  162.  
  163. procedure TMyWindow.Menu201( var Msg: TMessage);
  164. var
  165.   Result: integer;
  166. begin
  167.   GMulti := FALSE;
  168.   Result := Application^.ExecDialog( New( PGetAcc, Init( @Self, 'CHOOSEACC')));
  169.   if Result = id_OK then
  170.     Application^.ExecDialog( New( PTransact,
  171.       Init( @Self, GAccType, GAccNum, GAccType, GMulti)));
  172. end;
  173.  
  174. procedure TMyWindow.Menu205( var Msg: TMessage);
  175. begin
  176.   Application^.ExecDialog( New( PTransfer, Init( @Self, 'TRANSFER')));
  177. end;
  178.  
  179. procedure TMyWindow.Menu301( var Msg: TMessage);
  180. begin
  181.   if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
  182.   begin
  183.     Application^.ExecDialog( New( PAccBalance, Init( @Self, 'ACCBAL')));
  184.   end;
  185. end;
  186.  
  187. procedure TMyWindow.Menu302( var Msg: TMessage);
  188. begin
  189.   if Application^.ExecDialog( New( PGetAcc, Init( @Self, 'GETACC'))) = id_OK then
  190.   begin
  191.     Application^.ExecDialog( New( PTransRep, Init( @Self, 'HISTORY', GAccNum, FALSE)));
  192.   end;
  193. end;
  194.  
  195. procedure TMyWindow.Menu2;
  196. begin
  197.   TMDIWindow.Done;
  198. end;
  199.  
  200. {--------------------------------------------------}
  201. { TMyApplication's method implementations:         }
  202. {--------------------------------------------------}
  203.  
  204. procedure TMyApplication.InitMainWindow;
  205. begin
  206.   MainWindow := New( PMyWindow, Init( AppName, LoadMenu( HInstance, AppMenu)));
  207. end;
  208.  
  209. {--------------------------------------------------}
  210. { Main program:                                    }
  211. {--------------------------------------------------}
  212.  
  213. var
  214.   MyApp : TMyApplication;
  215.  
  216. begin
  217.   MyApp.Init( AppName);
  218.   MyApp.Run;
  219.   MyApp.Done;
  220. end.
  221.